{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import cinrad"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Read data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "f = cinrad.io.StandardData(r'T_RADR_I_Z9200_20181105023601_O_DOR_SAD_CAP_FMT.bin')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Attributes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{0: {'angular_reso': 1.0, 'radial_reso': 0.25, 'max_distance': 460.0}, 1: {'angular_reso': 1.0, 'radial_reso': 0.25, 'max_distance': 230.0}, 2: {'angular_reso': 1.0, 'radial_reso': 0.25, 'max_distance': 460.0}, 3: {'angular_reso': 1.0, 'radial_reso': 0.25, 'max_distance': 230.0}, 4: {'angular_reso': 1.0, 'radial_reso': 0.25, 'max_distance': 146.0}, 5: {'angular_reso': 1.0, 'radial_reso': 0.25, 'max_distance': 146.0}, 6: {'angular_reso': 1.0, 'radial_reso': 0.25, 'max_distance': 146.0}, 7: {'angular_reso': 1.0, 'radial_reso': 0.25, 'max_distance': 146.0}, 8: {'angular_reso': 1.0, 'radial_reso': 0.25, 'max_distance': 125.0}, 9: {'angular_reso': 1.0, 'radial_reso': 0.25, 'max_distance': 125.0}, 10: {'angular_reso': 1.0, 'radial_reso': 0.25, 'max_distance': 125.0}}\n"
     ]
    }
   ],
   "source": [
    "print(f.scanconfig)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`scanconfig` provides some important parameters in each scan"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Methods"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['TREF', 'REF', 'SQI', 'ZDR', 'RHO', 'PHI', 'KDP', 'SNRH', 'azimuth']\n"
     ]
    }
   ],
   "source": [
    "print(f.avaliable_product(0))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['VEL', 'SW', 'azimuth']\n"
     ]
    }
   ],
   "source": [
    "print(f.avaliable_product(1))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`avaliable_product` tells the product that can be found in the current scan.\n",
    "\n",
    "The sample data comes from a dual-polarized radar (SAD), for other types of radar, the polarized products are not provided."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "r = f.get_data(0, 230, 'REF')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Datatype: REF\n",
      "Station name: 广州\n",
      "Scan time: 20181105023601\n",
      "Elevation angle: 0.5\n",
      "Range: 230\n"
     ]
    }
   ],
   "source": [
    "print(r)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`get_data` is the methods to extract data, the parameters are `tilt`, `drange`, and `dtype`.\n",
    "\n",
    "Note: `reflectivity` and `velocity` methods are depreciated."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "masked_array(\n",
       "  data=[[--, --, --, ..., --, --, --],\n",
       "        [--, --, --, ..., --, --, --],\n",
       "        [--, --, --, ..., --, --, --],\n",
       "        ...,\n",
       "        [--, --, --, ..., --, --, --],\n",
       "        [--, --, --, ..., --, --, --],\n",
       "        [--, --, --, ..., --, --, --]],\n",
       "  mask=[[ True,  True,  True, ...,  True,  True,  True],\n",
       "        [ True,  True,  True, ...,  True,  True,  True],\n",
       "        [ True,  True,  True, ...,  True,  True,  True],\n",
       "        ...,\n",
       "        [ True,  True,  True, ...,  True,  True,  True],\n",
       "        [ True,  True,  True, ...,  True,  True,  True],\n",
       "        [ True,  True,  True, ...,  True,  True,  True]],\n",
       "  fill_value=1e+20)"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "All output data are instances of`maskedarray`."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
